package indi.zhifa.study2024.busy.generaltest.controller.simplecal;

import indi.zhifa.core.common.web.entity.ann.ZhiFaRestController;
import indi.zhifa.study2024.busy.generaltest.business.simplecal.entity.request.APlusBRequest;
import indi.zhifa.study2024.busy.generaltest.business.simplecal.entity.request.FabRequest;
import indi.zhifa.study2024.busy.generaltest.business.simplecal.entity.response.APlusBResponse;
import indi.zhifa.study2024.busy.generaltest.business.simplecal.entity.response.DivideZeroErrorResponse;
import indi.zhifa.study2024.busy.generaltest.business.simplecal.entity.response.FabResultResponse;
import indi.zhifa.study2024.busy.generaltest.business.simplecal.service.ISimpleCalService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

@Slf4j
@Validated
@RequiredArgsConstructor
@RequestMapping(value = "/class001/simpleCal")
@ZhiFaRestController
@Tag(name = "simpleCal")
public class SimpleCalController {

    private final ISimpleCalService mSimpleCalService;

    @Operation(summary = "aPlusB(a+b)")
    @PostMapping("/aPlusB")
    public APlusBResponse plus(@RequestBody APlusBRequest pRequest)
    {
        APlusBResponse aPlusBResponse = mSimpleCalService.plus(pRequest);
        return aPlusBResponse;
    }

    @Operation(summary = "fab(斐波那契数列)")
    @PostMapping("/fab")
    public FabResultResponse fab(@RequestBody FabRequest pRequest)
    {
        FabResultResponse fabResultResponse = mSimpleCalService.fab(pRequest);
        return fabResultResponse;
    }

    @Operation(summary = "除0测试")
    @GetMapping("/divideZero")
    public DivideZeroErrorResponse divideZero()
    {
        DivideZeroErrorResponse divideZeroErrorResponse = mSimpleCalService.divideZero();
        return divideZeroErrorResponse;
    }

}
